package com.huanhuan.index;

import org.apache.http.HttpHost;


import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

public class ESTest_Client_Index_Delete {

    public static void main(String[] args) throws Exception {

        final String hostname = "localhost";
        final int port = 9200;
        final String schema = "http";

        HttpHost httpHost = new HttpHost( hostname, port, schema );

        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(httpHost)
        );


        //删除索引操作
        DeleteIndexRequest response = new DeleteIndexRequest( "huan" );

        AcknowledgedResponse delete = client.indices().delete( response, RequestOptions.DEFAULT );

        boolean acknowledged = delete.isAcknowledged();

        System.out.println("删除状态："+acknowledged);

        client.close();

    }


}
